package com.neuedu.amqp.publisher.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 金山
 * 项目：sca-all-in-one
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2025/6/510:57
 */
@RestController
public class PublisherController {
    @Autowired
    public RabbitTemplate rabbitTemplate;


    @RequestMapping("/send")
    public String send(String msg) {
        // 队列名称
        String queueName = "simple.queue";
        // 消息
        String message = !StringUtils.isEmpty(msg) ? msg : "send phone msg ,phonenum:13888888888";
        // 发送消息
        rabbitTemplate.convertAndSend(queueName, message);

        return "success";
    }


}
